package com.soft.javase.day06.regex;

import java.util.Scanner;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/4/24
 */
public class ValidUsername {
    public static boolean isValidUsername(String username) {
        String regex = "^[a-zA-Z][a-zA-Z0-9_]{5,11}$";
        return username.matches(regex);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username = sc.nextLine();
        if (isValidUsername(username)) {
            System.out.println("用户名有效！");
        } else {
            System.out.println("用户名无效！必须以英文开头,只能包含英文,数字和_;最少6位,做多12位");
        }
    }
}
